import { Router } from "express";
import {
  getTodos,
  addTodo,
  deleteTodo,
  toggleDone,
  getTodo,
} from "../controllers/todos.constroller";
import { auth } from "../middleware/auth"; // 登录认证中间件

const router = Router();
router.use(auth);

/**
 * @route   GET /api/todos
 * @desc    获取当前用户的所有待办
 * @access  Private
 */
router.get("/", getTodos);

/**
 * @route   POST /api/todos
 * @desc    添加新的待办
 * @access  Private
 */
router.post("/", addTodo);
/**
 * @route   GET /api/todos/:id
 * @desc    查看指定待办
 * @access  Private
 */
router.get("/:id", getTodo);
/**
 * @route   DELETE /api/todos/:id
 * @desc    删除指定待办
 * @access  Private
 */
router.delete("/:id", deleteTodo);

/**
 * @route   put /api/todos/:id
 * @desc    切换待办完成状态
 * @access  Private
 */
router.put("/:id", toggleDone);

export default router;
